package com.jxd.ordersys.service.impl;

import com.jxd.ordersys.dao.DeptMapper;
import com.jxd.ordersys.model.Dept;
import com.jxd.ordersys.service.IDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @ClassName DeptServiceImpl
 * @Description TODO
 * @Author 王云超
 * @Date 2024/9/19 16:46
 * @Version 1.0
 */
@Service
public class DeptServiceImpl implements IDeptService {
    @Autowired
    DeptMapper deptMapper;
    @Override
    public List<Dept> deptList() {
        return deptMapper.deptList();
    }

    @Override
    public boolean addDept(Dept dept) {
        return deptMapper.addDept(dept)>0;
    }

    @Override
    public boolean editDept(Dept dept) {
        return deptMapper.editDept(dept)>0;
    }

    @Override
    public boolean delDept(List<Integer> deptIds) {
        return deptMapper.delDept(deptIds)>0;
    }

    @Override
    public List<Dept> getDeptByPage(Integer page, Integer limit, String deptName) {
        // 计算分页偏移量
        int offset = (page - 1) * limit;
        return deptMapper.getDeptByPage(offset,limit,deptName);
    }

    @Override
    public int getDeptCount(String deptName) {
        return deptMapper.getDeptCount(deptName);
    }

    @Override
    public Dept getDeptById(Integer deptId) {
        return deptMapper.getDeptById(deptId);
    }

}